package com.yuexun.dhdoctor.module.login.presenter.impl;

import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.login.bean.AreaBean;
import com.yuexun.dhdoctor.module.login.model.IAreaHospModel;
import com.yuexun.dhdoctor.module.login.presenter.IAreaHospPresenter;
import com.yuexun.dhdoctor.module.login.ui.view.IAreaHospView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2017/12/14 0014.
 */

public class AreaHospPresenter implements IAreaHospPresenter {
    private IAreaHospView view;
    private IAreaHospModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public AreaHospPresenter(IAreaHospModel model, IAreaHospView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void inquireAreaWithHospList(Map<String, String> praise) {
        model.inquireAreaWithHospList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<AreaBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取区域医院失败:" + e.toString());
                    }

                    @Override
                    public void onNext(BaseEntity<AreaBean> baseEntity) {
                        view.getAreaWithHospList(baseEntity);
                    }
                });
    }
}
